<?php
function parseString($str_parse,$data=''){
	$res=$str_parse;
	if(is_array($data)&& !empty($str_parse)){
		foreach($data as $index => $content){
			$aux_text="%".$index."%";
			$res = str_replace($aux_text, $content, $res);
		}
	}
	return $res;
}
function sendEmail($email_object,$to_data,$subject,$message,$parse_data='',$section='',$mail_config_model=null){
	$config['protocol'] = 'sendmail';
	$config['mailpath'] = '/usr/sbin/sendmail';
	$config['charset'] = 'UTF-8';
	$config['wordwrap'] = TRUE;
	$config['mailtype'] = 'html';	
	$email_object->initialize($config);
	$res="";
	$email_object->from('info@landmark.com', 'The Land Mark Company');
	$email_object->to($to_data);
	
	if($section!="" && $mail_config_model!=null){
		
	//$section_from=$section."_from";
		$by_from=array(
			"section"	=>$section,
			"item"		=>"from"		
				);
		$aux_res_from=$mail_config_model->getByOrderBy($by_from);
		$res_from=$aux_res_from[0];
		
		
		//$section_to=$section."_to";
		$by_to=array(
				"section"=>$section,
				"item"	 =>"to"		
				);
		$aux_res_to=$mail_config_model->getByOrderBy($by_to);
		$res_to=$aux_res_to[0];
		if($to_data!=""){
			$res_to["value"]=$to_data.",".$res_to["value"];
		}
		
		$email_object->from($res_from["value"], 'The North West Company');
		$email_object->to($res_to["value"]);
	}
	
	//$email_object->cc('webmaster@northwest.ca');
	$email_object->subject($subject);
	$message=parseString($message,$parse_data);
	$email_object->message($message);
	$email_object->send();
	$res=$email_object->print_debugger();
	return $res;
}



function getCurrentController(){
	$c_show='c1';
	if(ereg("home",$_SERVER['PHP_SELF']))					$c_show='c1';
	if(ereg("about",$_SERVER['PHP_SELF']))					$c_show='c2';
	if(ereg("company_profile",$_SERVER['PHP_SELF']))		$c_show='c2';
	if(ereg("history",$_SERVER['PHP_SELF']))				$c_show='c2';
	if(ereg("execs",$_SERVER['PHP_SELF']))					$c_show='c2';
	if(ereg("board",$_SERVER['PHP_SELF']))					$c_show='c2';
	if(ereg("investor",$_SERVER['PHP_SELF']))				$c_show='c3';
	if(ereg("webcast",$_SERVER['PHP_SELF']))				$c_show='c3';
	if(ereg("releases",$_SERVER['PHP_SELF']))				$c_show='c3';
	
	if(ereg("news/index",$_SERVER['PHP_SELF']))						$c_show='c4';
	if(ereg("releases/index",$_SERVER['PHP_SELF']))					$c_show='c4';
	if(ereg("webcast/index",$_SERVER['PHP_SELF']))					$c_show='c4';
	
	if(ereg("events",$_SERVER['PHP_SELF']) && !ereg("wintering_partner_conference",$_SERVER['PHP_SELF']) && !ereg("register_wintering",$_SERVER['PHP_SELF']))					$c_show='c4';
	if(ereg("newroom",$_SERVER['PHP_SELF']))				$c_show='c4';
	if(ereg("operations",$_SERVER['PHP_SELF']))				$c_show='c5';
	if(ereg("community",$_SERVER['PHP_SELF']))				$c_show='c7';
	if(ereg("responsibility",$_SERVER['PHP_SELF']))			$c_show='c7';
	if(ereg("healthy",$_SERVER['PHP_SELF']))				$c_show='c7';
	if(ereg("wellness",$_SERVER['PHP_SELF']))				$c_show='c7';
	if(ereg("investing_people",$_SERVER['PHP_SELF']))		$c_show='c7';
	if(ereg("canadian_diabetes",$_SERVER['PHP_SELF']))		$c_show='c7';
	if(ereg("canadian_museum",$_SERVER['PHP_SELF']))		$c_show='c7';
	if(ereg("united_way",$_SERVER['PHP_SELF']))				$c_show='c7';
	if(ereg("corporate_chart",$_SERVER['PHP_SELF']))		$c_show='c7';
	if(ereg("national_aboriginal",$_SERVER['PHP_SELF']))	$c_show='c7';
	if(ereg("stories",$_SERVER['PHP_SELF']))				$c_show='c7';
	if(ereg("gibraltar",$_SERVER['PHP_SELF']))				$c_show='c7';
	if(ereg("economic",$_SERVER['PHP_SELF']))				$c_show='c7';
	if(ereg("unitholders",$_SERVER['PHP_SELF']))			$c_show='c7';
	if(ereg("employing_locally",$_SERVER['PHP_SELF']))		$c_show='c7';
	if(ereg("greener",$_SERVER['PHP_SELF']))		$c_show='c7';
	if(ereg("sponsor_ship",$_SERVER['PHP_SELF']))			$c_show='c7';
	if(ereg("going_green",$_SERVER['PHP_SELF']))			$c_show='c7';
	if(ereg("environmental",$_SERVER['PHP_SELF']))			$c_show='c7';
	if(ereg("peopleHabitat",$_SERVER['PHP_SELF']))			$c_show='c7';
	if(ereg("donations",$_SERVER['PHP_SELF']))		        $c_show='c7';
	if(ereg("careers",$_SERVER['PHP_SELF']))				$c_show='c8';
	if(ereg("our_culture",$_SERVER['PHP_SELF']))			$c_show='c8';
	if(ereg("corporate_opportunities",$_SERVER['PHP_SELF']))	$c_show='c8';
	if(ereg("load_form",$_SERVER['PHP_SELF']))	$c_show='c8';
	if(ereg("distribution_opportunities",$_SERVER['PHP_SELF']))	$c_show='c8';
	if(ereg("store_oportunities",$_SERVER['PHP_SELF']))		$c_show='c8';
	
	echo "<script type='text/javascript' language='javascript'>xShow('".$c_show."')</script>";

}

function getSizeFile($url) {
	if( file_exists($url)) {
		$size = round(filesize($url)/1024,2);
		echo $size." Kb";
		return $size;
	} else {}
	
}
function getSizeFileReal($url) {
	if( file_exists($url)) {
		$size = round(filesize($url)/1024,2);
		return $size." KB";
	} else {}
	
}

function serializeArray($array){
	$tmp = serialize($array);
    $tmp = urlencode($tmp);
    return $tmp;
}

function unserializeArray($url_array) {
	$tmp = stripslashes($url_array);
    $tmp = urldecode($tmp);
    $tmp = unserialize($tmp);
   return $tmp;
}
function getTradingStatsContent($aux_height=''){
	$aux_height= $aux_height!=""?$aux_height:151;
	$res ="<div class='box_center_1'>
    <div class='image_in_box'>
	<a class='big_video_repeat'  href='".base_url()."company_profile/show_videos' title='The North West Company - Company Profile'>
	<div id='img_box_four_hover'></div>
	</a>	 
	</div>
    </div>
    <div class='box_center_trading'>
     <div class='image_in_box_trading'><img src='http://www.tsx.com/en/images/gifquotes/NWF.gif' alt='Trading Stats' width='205px' height='$aux_height' style='top: -1px;' border='0'/></div>
    </div>";
    
    $res="<div class='box_center_1'>
    <div class='image_in_box'>
	<a class='nwc_fund_aux' target='_blank' title='North West Company Fund' href='".base_url()."home/nwc_fund'><img src='".base_url()."system/resources/volleyball/img/frontend/trading_stats.jpg' alt='Trading Stats' border='0'/></a>
	</div>
    </div>
    <div class='box_center_trading'>
     <div class='image_in_box_trading'><img src='http://www.tsx.com/en/images/gifquotes/NWF.gif' alt='Trading Stats' width='205px' height='151px' style='top: -1px;' border='0'/></div>
    </div>";
	
	return $res;
}
function get_company_profile($aux_height=''){
	$aux_height= $aux_height!=""?$aux_height:151;
	$res ="<div class='image_in_box'>
	<a class='big_video_repeat'  href='".base_url()."company_profile/show_videos' title='The North West Company'>
	<div id='img_box_four_hover'></div></a>	 
	</div>
    ";
    return $res;
}
function getTradingStatsContent1(){
	$res='	<div class="box_center">
		<div class="image_in_box">
	 	<img src="'.base_url().'system/resources/volleyball/img/frontend/home/img_box_four.png" alt="Trading Stats" border="0" />
		</div>
		<div class="text_in_box">
		<p>Last:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(16.40)</p>
		<p>Change:&nbsp;&nbsp;<span class="text_red">+ 0.080 (+0.52)</span></p>
		<p>Volume:&nbsp;&nbsp;59,789</p>
		<p style="padding-top: 25px; padding-bottom:5px;">3:11 PM ET January 14, 2009</p>
		</div>
		</div>
		<div class="box_footer"></div>';
	
	$res="<div class='box_center_1'>
     <div class='image_in_box'>
	 <img src='".base_url()."system/resources/volleyball/img/frontend/home/img_box_four.png' alt='Trading Stats' border='0'/>
	 
	 </div>
	 
	 
    </div>
    <div class='box_center_trading'>
     <div class='image_in_box_trading'><img src='http://www.tsx.com/en/images/gifquotes/NWF.gif' alt='Trading Stats' width='205px' height='151px' style='top: -1px;' border='0'/></div>
    </div>";
	
	 $res="<div class='box_center_1'>
    <div class='image_in_box'>
	<a class='nwc_fund_aux' target='_blank' title='North West Company Fund' href='".base_url()."home/nwc_fund'><img src='".base_url()."system/resources/volleyball/img/frontend/trading_stats.jpg' alt='Trading Stats' border='0'/></a>
	</div>
    </div>
    <div class='box_center_trading'>
     <div class='image_in_box_trading'><img src='http://www.tsx.com/en/images/gifquotes/NWF.gif' alt='Trading Stats' width='205px' height='151px' style='top: -1px;' border='0'/></div>
    </div>";
	return $res;
}
function getQuarterSuffix($quarter){
		$res="";
		if($quarter==1){
			$res=$quarter."st";
		}
		if($quarter==2){
			$res=$quarter."nd";
		}
		if($quarter==3){
			$res=$quarter."rd";
		}
		if($quarter==4){
			$res=$quarter."th";
		}
		return $res;
	}
function getQuarterText($quarter){
		$res="";
		if($quarter==1){
			$res="First";
		}
		if($quarter==2){
			$res="Second";
		}
		if($quarter==3){
			$res="Third";
		}
		if($quarter==4){
			$res="Fourth";
		}
		return $res;
	}
function getHomeTopBoxes(){
	$res='<tr>
        	<td width="33%" align="left">
            	<div id="box_newsletter">
                    <div class="div_top_box"></div>
                    <div class="div_bottom_box">
							<p  class="top_boxes_text"> Sign up to receive the latest news and  specials by email from TeamLeader!</p>
                			
		                <div id="newID_newsletter_email" class="white_error newsletter_input">
                        <div id="newsletter_form_div">
                        <form action="#" method="" id="form_newsletter" onSubmit="">
                         <input class="validate[required,custom[email_newsletter]]" type="text"  name="newsletter_email" id="newsletter_email"  value="ENTER YOUR EMAIL HERE"  /><input type="submit" id="newsletter_submit" name="" value=" "  /></form>
                         <div style="clear:both;"></div>
                         </div>
						 <div id="loading_image" style="display:none">Processing  <img src="'.base_url().'system/resources/volleyball/img/frontend/ajax-loader.gif" /></div>
                         </div>
                    	<div id="error_newsletter" style="display:none;"></div>
                    </div>
                </div>
            </td>
            <td width="34%" align="center" >
	            <div id="box_catalog">
				<a  target="_blank" href="http://www.teamleader.com/digitalpublicationframeset.html?width=1270&height=711" onmouseover="this.style.cursor = \'hand\';">
                <div class="div_top_left_box"></div>
                <div class="div_top_right_box"></div>
                <div class="div_bottom_left_box">
                    <p class="top_boxes_text">Check out the 2010 volleyball catalog here!</p>
                    <p class="top_boxes_text_sec">Loads of new styles in <br>Uniforms, Accesories, Warm-Ups and more!</p>
                </div>
                <div class="div_bottom_right_box" ></div>
				</a>
                </div>
            </td>
            <td  width="33%" align="right">
            	<div id="box_coloring">
				<a  href="'.base_url().'volleyball/color/home"  onmouseover="this.style.cursor = \'hand\';">
                <div class="div_top_left_box"></div>
                <div class="div_top_right_box"></div>
                <div class="div_bottom_left_box">
                	<p class="top_boxes_text"> Design, color and print your uniform before<br  />you buy. Experiment<br  /> and find the look for you.</p>
                    <p class="top_boxes_text_sec">Click here to start.</p>
               	</div>
                <div class="div_bottom_right_box"></div>
				</a>
                </div>
            </td>
        </tr>';
		return $res;
}
function getRightBoxes(){
	$res='<table id="size_box" width="100%">
			<tr>
        	<td width="100%" align="center">
            	<div id="box_newsletter">
                    <div class="div_top_box"></div>
                    <div class="div_bottom_box">
							<p  class="top_boxes_text"> Sign up to receive the latest news and  specials by email from TeamLeader!</p>
                			
		                <div id="newID_newsletter_email" class="white_error newsletter_input">
                        <div id="newsletter_form_div">
                        <form action="#" method="" id="form_newsletter" onSubmit="">
                         <input class="validate[required,custom[email_newsletter]]" type="text"  name="newsletter_email" id="newsletter_email"  value="ENTER YOUR EMAIL HERE"  /><input type="submit" id="newsletter_submit" name="" value=" "  /></form>
                         <div style="clear:both;"></div>
						 </div>
						 <div id="loading_image" style="display:none">Processing  <img src="'.base_url().'system/resources/volleyball/img/frontend/ajax-loader.gif" /></div>
                         </div>
						 <div id="error_newsletter" style="display:none;"></div>
                         </div>
                    	
                    </div>
                </div>
            </td>
		</tr>
		<tr>
            <td width="100%" align="center" >
	            <div id="box_catalog">
                <div class="div_top_left_box"></div>
                <a class=" div_top_right_box" href="#"></a>
                <div class="div_bottom_left_box">
                    <p class="top_boxes_text">Check out the 2010 cheer catalog here!
                    <br /><br />
                    Loads of new styles in Uniforms,Campwear, Warm-Ups and more!</p>
                </div>
                <a class="div_bottom_right_box" href="#"></a>
                </div>
            </td>
		</tr>
            <td  width="100%" align="center">
            	<div id="box_coloring">
                <div class="div_top_left_box"></div>
                <a class="div_top_right_box" href="'.base_url().'colorbook"></a>
                <div class="div_bottom_left_box">
                	<p class="top_boxes_text"> Design, color and print your uniform before<br  />you buy. Experiment<br  /> and find the look for you.<br /><br />
                    <a class="top_box_link" href="'.base_url().'colorbook">Click here to start</a></p>
               	</div>
                <a class="div_bottom_right_box" href="'.base_url().'colorbook"></a>
                </div>
            </td>
        </tr>
		</table>';
		$res='
			<table id="size_box" width="100%">
			<tr height="141">
        	<td width="100%" align="center">
            	<div id="box_newsletter">
                    <div class="div_top_box"></div>
                    <div class="div_bottom_box">
							<p  class="top_boxes_text"> Sign up to receive the latest news and  specials by email from TeamLeader!</p>
                			
		                <div id="newID_newsletter_email" class="white_error newsletter_input">
                        <div id="newsletter_form_div">
                        <form action="#" method="" id="form_newsletter" onSubmit="">
                         <input class="validate[required,custom[email_newsletter]]" type="text"  name="newsletter_email" id="newsletter_email"  value="ENTER YOUR EMAIL HERE"  /><input type="submit" id="newsletter_submit" name="" value=" "  /></form>
                         <div style="clear:both;"></div>
                         </div>
						 <div id="loading_image" style="display:none">Processing  <img src="'.base_url().'system/resources/volleyball/img/frontend/ajax-loader.gif" /></div>
                         </div>
                    	<div id="error_newsletter" style="display:none;"></div>
                    </div>
                </div>
            </td>
			</tr>
            <tr height="141">
        	<td width="100%" align="center">
	            <div id="box_catalog">
				<a target="_blank" href="http://www.teamleader.com/digitalpublicationframeset.html?width=1270&height=711" onmouseover="this.style.cursor = \'hand\';">
                <div class="div_top_left_box"></div>
                <div class="div_top_right_box"></div>
                <div class="div_bottom_left_box">
                    <p class="top_boxes_text">Check out the 2010 volleyball catalog here!</p>
                    <p class="top_boxes_text_sec">Loads of new styles in<br>Uniforms, Campwear, Warm-Ups and more!</p>
                </div>
                <div class="div_bottom_right_box" ></div>
				</a>
                </div>
            </td>
			</tr>
			<tr height="141">
        	<td width="100%" align="center">
				<div id="box_coloring">
				<a href="'.base_url().'color/home"  onmouseover="this.style.cursor = \'hand\';">
                <div class="div_top_left_box"></div>
                <div class="div_top_right_box"></div>
                <div class="div_bottom_left_box">
                	<p class="top_boxes_text"> Design, color and print your uniform before<br  />you buy. Experiment<br  /> and find the look for you.</p>
                    <p class="top_boxes_text_sec">Click here to start.</p>
               	</div>
                <div class="div_bottom_right_box"></div>
				</a>
                </div>
            </td>
        </tr>
			</table>
		';
		return $res;
}

?>